<template>
	<view class="wrap" style="padding-bottom: 60px;">
	<view class="list-cell">
	<!-- 	<image class="user-images" src="/static/aidex/images/user06.png"></image> -->
		<view class="user-name">
			<span>{{model.nickName}}</span><!-- <u-icon size="32" color="#f04d94" name="woman"></u-icon> --><br>
		</view>
	</view>
		<u-cell-group :border="false" :model="model" :rules="rules" ref="uForm"  >
			<u-gap height="20" bg-color="#f5f5f5"></u-gap>
			<u-cell-item title="用户名"  v-model="model.phonenumber" :title-width="180" :arrow="false"></u-cell-item>
			<u-cell-item title="姓名"  class="user-other"  v-model="model.nickName"  :title-width="180" :arrow="false"></u-cell-item>
		    <u-cell-item title="性别"    v-model="model.sex"  :title-width="180" :arrow="false"></u-cell-item>
			<u-cell-item title="身份证号"    v-model="model.idCard" :title-width="180" :arrow="false"></u-cell-item>
			<u-cell-item title="单位"    v-model="model.company" icon="home" :title-width="180" :arrow="false"></u-cell-item>
		    <u-cell-item title="血型"    v-model="model.bloodType"  :title-width="180" :arrow="false"></u-cell-item>
			<u-cell-item title="手机号"  class="connect" icon="phone"  v-model="model.phonenumber"   :title-width="180" @click="navTo('/pages/sys/user/modify')"></u-cell-item>
			<u-gap height="20" bg-color="#f5f5f5"></u-gap>	
		</u-cell-group>
		<view class="form-footer">
			<u-button class="btn" type="primary" @click="submit">订阅医院公告</u-button>
			<!-- <u-button class="btn" type="default" @click="cancel">关闭</u-button> -->
		</view>
	</view>
	
</template>
<script>
/**
 * Copyright (c) 2013-Now http://aidex.vip All rights reserved.
 */
export default {
	data() {
		return {
			model: {
				userId: "",
				userName: "",
				sex: "",
				email: "",
				avatar: "",
				phonenumber: "",
				officeTel: "",
				idCard: "",
				bloodType: "",
				company:""
			},
			rules: {

			},
			avatarBase64: ''
		};
	},
	onLoad() {
		this.$u.api.getUserInfo().then(res => {
			if (res.code == '200'){
				this.model = {
					userId: res.user.userId,
					nickName: res.user.nickName,
					sex: res.user.sex,
					email: res.user.email,
					avatar: res.user.avatar,
					phonenumber: res.user.phonenumber,
					officeTel: res.user.officeTel,
					idCard: res.user.idCard,
					bloodType: res.user.bloodType,
				    company:res.user.company
			  }
			}else if (res.code == '401'){
				uni.reLaunch({
					url: '/pages/sys/login/index'
				});
			}else{
				this.$u.toast(res.message);
			}
		});
		uni.$on('uAvatarCropper', path => {
			this.avatarBase64 = path;
		})
	},
	computed: {
		avatarUrl() {
			if (this.avatarBase64 != ''){
				return this.avatarBase64;
			}
			let url = this.vuex_config.baseUrl+ this.vuex_user.avatar ||  '/static/aidex/tabbar/my_2.png';
			url = this.replaceAll(url,'\\','/');
			//url = url.replace('/aidex/', this.vuex_config.baseUrl + '/');
			/* alert(url); */
			return url;
		}
	},
	onReady() {
		//this.$refs.uForm.setRules(this.rules);
	},
	methods: {
		navTo(url) {
			uni.navigateTo({
				url: url
			});
		},
		chooseAvatar() {
			this.$u.route({
				url: '/uview-ui/components/u-avatar-cropper/u-avatar-cropper',
				params: {
					destWidth: 200, // 输出图片宽高
					rectWidth: 200, // 裁剪框的宽高
					fileType: 'jpg', // 输出的图片类型，如果'png'类型发现裁剪的图片太大，改成"jpg"即可
				}
			})
		},
		submit() {
				uni.requestSubscribeMessage({
								//数组，最多放三个订阅模板的ID
									tmplIds: ['SANOZnhIgeTvole_wXYMIVA3Koy9UR0Cdh0bAJo-7so'],
									success: function(res) {
			
			
									},
									fail: function() {
							
									},
									complete: (res) => {
									}
								});
			
			
		},
		cancel() {
			uni.navigateBack();
		}
	}
};
</script>
<style lang="scss" scoped>
	page{
		background: #f5f5f5;
	}
	.u-form{
		background: #fff;
		padding:0 15px;
	}
.u-size-medium{
    height: 60rpx;
    line-height: 60rpx;
    padding: 0 20px;
	font-size:28rpx;
	background-color: rgba(0, 0, 0, 0.1);
	color:#fff;
	border: 1px solid #5186e7;
}
.u-hairline-border:after{
	border: 1px solid #5186e7!important;
}
.input-placeholder{
	text-align: right;
}
.u-input{
	text-align: right !important;
}
.u-form-item{
	font-size:36rpx;
}
.list-cell {
	display: flex;
	box-sizing: border-box;
	width: 100%;
	padding: 10px 24rpx;
	overflow: hidden;
	color: #323233;
	font-size: 14px;
	line-height: 24px;
	background-color: #fff;
	align-items: center;
	
}
.user-images{
	width: 80rpx;
	height: 80rpx;
	margin-right: 10px;
}
.user-name{
	font-size: 32rpx;
	color: #000000;
	span{
	}
	.user-other{
		font-size: 26rpx;
		color: #999999;
		font-weight: normal;
	}
}
</style>
